//
//  DBDevices.h
//  CareRingApp
//
//  Created by Linktop on 2022/6/7.
//  绑定设备表

#import <Foundation/Foundation.h>
#import "HMDBManager.h"
#import "SRDeviceInfo.h"
NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, DBDEVICE_CHARGE_TYPE) {
    CHARGE_UNKNOW = -1, // Charging type not obtained
    CHARGE_MA = 0,      // Magnetic charging
    CHARGE_WILESS = 1,  // Wireless charging
    CHARGE_NFC = 2,     // NFC charging
};

typedef NS_ENUM(NSUInteger, RING_PROJECT_ID) {
    PROJ_NOT_SUPPORT = 0, //旧的设备版本 不支持此参数
    PROJ_SR03 = 0x10,//项目:0x10 (00010000)
    PROJ_SRO9W = 0x20  ,//无线充电: 0x20(00100000)
    PROJ_SRO9N = 0x21 ,//NFC 充电: 0x21(00100001)
    PROJ_SR01A = 0x22 ,//项目:0x22(00100010)
    PROJ_SR23_NFC = 0x30 ,//NFC 充电: 0x30 (00110000)
    PROJ_SR26 = 0x40 ,//低成本戒指项目:0x40(01000000)
};



@class DeviceOtherInfo;

@interface DBDevices : NSObject
@property(assign, nonatomic)NSNumber *cId;
@property(strong, nonatomic)NSString *macAddress;

@property(strong, nonatomic)DeviceOtherInfo *otherInfo;  //设备其他信息




//创建数据库
+(void)createTable;
+(void)queryAllByCpmplete:(void(^)(NSMutableArray<DBDevices *> *results))cmpBlk;

-(void)insert:(void(^)(BOOL succ))complete;

-(void)updateOtherInfo:(void(^)(BOOL succ))complete;

-(void)deleteFromTable:(void (^)(void))cmpBlk;

-(void)chooseOTAugument:(void(^)(NSString * _Nullable cat))blk;

@end

@interface DeviceOtherInfo :NSObject

@property(assign, nonatomic)DEV_COLOR color;
@property(assign, nonatomic)NSInteger size;
@property(strong, nonatomic)NSString *sn, *fireWareVersion;
@property(assign, nonatomic)MAIN_CHIP_TYPE mainChipType; // 主芯片型号
@property(assign, nonatomic)NSUInteger deviceGeneration;  // 迭代版本
@property(assign, nonatomic)BOOL isSupportSportMode;
@property(assign, nonatomic)BOOL isSupportEcg;
@property(assign, nonatomic)RING_PROJECT_ID projectId;

@property(assign, nonatomic)DBDEVICE_CHARGE_TYPE chargeType;

-(NSString *)jsonString;
-(NSDictionary *)parseJasonString:(NSString *)jsonString;

/// 转换为 a.b.c格式
-(NSString *)transFirmVersionToRemoteType;




@end

NS_ASSUME_NONNULL_END
